//
//  HomeGoodsCell.m
//  MindBox
//
//  Created by MS on 16-1-4.
//  Copyright (c) 2016年 Lemon. All rights reserved.
//

#import "HomeGoodsCell.h"
#import "UIImageView+WebCache.h"
@interface HomeGoodsCell ()
@property (weak, nonatomic) IBOutlet UIImageView *imageView;

@property (weak, nonatomic) IBOutlet UILabel *titleView;

@property (weak, nonatomic) IBOutlet UILabel *priceView;
@property (weak, nonatomic) IBOutlet UILabel *likeCountView;

@end

@implementation HomeGoodsCell

+(instancetype)cellWithcollectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    
    NSString * className = NSStringFromClass([self class]);
    UINib *  nib = [UINib nibWithNibName:className bundle:nil];
    [collectionView registerNib:nib forCellWithReuseIdentifier:className];
    return [collectionView dequeueReusableCellWithReuseIdentifier:className forIndexPath:indexPath];
    
}


-(void)setGoodsData:(GoodsData *)goodsData
{
    _goodsData = goodsData;
   
    [self setValuesWithImage_url:goodsData.image_url title:goodsData.short_name price:goodsData.p_price likeCount:goodsData.like_count];
}

-(void)setGiftGoods:(Gift_ItemGoods *)giftGoods
{
    _giftGoods = giftGoods;
    
    [self setValuesWithImage_url:giftGoods.image_url title:giftGoods.short_name price:giftGoods.p_price likeCount:giftGoods.like_count];
}

-(void)setValuesWithImage_url:(NSString *)image_url title:(NSString *)title price:(NSString *)price likeCount:(NSString *)like_count
{
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:image_url]];
    
    self.titleView.text = title;
    
    NSString * priceStr = [NSString stringWithFormat:@"¥ %.2f",[price floatValue]];
    self.priceView.text = priceStr;
    
    self.likeCountView.text = like_count;
}


- (void)awakeFromNib {
    // Initialization code
}

@end
